<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="0">
<meta name="renderer" content="webkit"/>
<meta name="force-rendering" content="webkit"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>
<title>登录</title>
<link href="css/login.css" type="text/css" rel="stylesheet">
</head>
<body>
	<div class="login">
		<div class="message">后台管理系统</div>
		<div id="darkbannerwrap"></div>
		<form id="login-form" method="post" onsubmit="return false;">
			<input id="username" name="username" placeholder="用户名" type="text"
				autocomplete="off">
			<hr class="hr15">
			<input id="password" name="password" placeholder="密码" type="password"
				autocomplete="off">
			<hr class="hr15">
			<div>
				<input id="identiryCode" name="code" maxlength="6" class="user-content" type="text" style="width: 208px;height: 40px;color: #555555;"  placeholder="请输入验证码"/>
				<a class=""><img onclick="reloadCode()" id="indeityImgLogin" src="getCode?width=80" style="width:130px;height:40px;float:left;"/></a>
			</div>
			<hr class="hr15">
			<div style="font-size:15px;float: right;margin-right: 30px;">
				<input name="remember-me" id="remember-me" type="checkbox" style="vertical-align:middle;zoom:150%;" value="true"/>
				<label for="remember-me" style="vertical-align:middle; font-size: 15px;">记住我</label>
			</div>
			<hr class="hr15">
			<button style="width: 100%;" type="submit"
				onclick="login(this)">登录</button>
			<hr class="hr20">
			<span id="info" style="color: red"></span>
		</form>
		<div class="signup-footer">
            <div class="pull-left">
                &copy; 2018 All Rights Reserved. 镜水灵动
            </div>
        </div>
	</div>

</body>
<script src="js/libs/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
	if (top != self) {
		parent.location.href = '/login.html';
	}

	function login(obj) {
		$(obj).attr("disabled", true);

		var username = $.trim($('#username').val());
		var password = $.trim($('#password').val());
		if (username == "" || password == "") {
			$("#info").html('<div style="font-size:15px">用户名或者密码不能为空</div>');
			$(obj).attr("disabled", false);
		} else {
			$.ajax({
				type : 'post',
				url : '/login',
				data : $("#login-form").serialize(),
				success : function(data) {
					location.href = '/index.html';
				},
				error : function(xhr, textStatus, errorThrown) {
					var msg = xhr.responseText;
					var response = JSON.parse(msg);
					$("#info").html('<div style="font-size:15px">'+response.message+'</div>');
					$(obj).attr("disabled", false);
				}
			});

		}
	}
	function reloadCode(){
		document.getElementById("indeityImgLogin").src = "getCode?ticket=" + Math.random();
	}
</script>
</html>